package com.spica.spicaschool.ui.mydiary

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.drakeet.multitype.MultiTypeAdapter
import com.spica.spicaschool.bean.PageEntity
import com.spica.spicaschool.bean.diary.Diary
import com.spica.spicaschool.view.ListLayout

/**
 * 我的发布内容列表
 */
private const val TYPE_SIGN = "ANO"

class MyDiariesFragment : Fragment() {

    private var ano = 0 //公开日记&私人日记

    private val items = mutableListOf<Diary>()

    private lateinit var adapter: MultiTypeAdapter

    private var isOk = false // 是否完成View初始化

    private var isFirst = true // 是否为第一次加载

    private lateinit var listLayout: ListLayout

    private val page = PageEntity()

    companion object {
        fun newInstance(ano: Int = 0): Fragment {
            val fragment = MyDiariesFragment()
            val bundle = Bundle()
            bundle.putInt(TYPE_SIGN, ano)
            fragment.arguments = bundle
            return fragment
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        listLayout = ListLayout(requireContext())
        return listLayout
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    }

    private fun init() {
        // 获取传入类型
        val bundle = arguments
        if (bundle != null) ano = bundle.getInt(TYPE_SIGN)

    }

    override fun onResume() {
        super.onResume()
        initLoadData()
    }

    private fun initLoadData() {

        isFirst = false // 加载第一次数据后改变状态，后续不再重复加载

    }


}